package cn.buaa.HLJ.test;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpHost;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

public class Proxytest implements  PageProcessor,Runnable {

	private Site site;

	@Override
	public void run() {
		String s="http://www.apec.org/Press/News-Releases.aspx";
		List<String> url = new ArrayList<String>();
		url.clear();
		url.add(s.replaceAll("\"", "%22"));
		Spider.create(this).startUrls(url).run(); 
		
	}

	@Override
	public Site getSite() {
		//63.149.98.218
		//site = Site.me().setSleepTime(0).setRetryTimes(5).setCycleRetryTimes(3).setTimeOut(60000).setHttpProxy(new HttpHost("202.194.101.150",80));
		site = Site.me().setSleepTime(0).setRetryTimes(5).setCycleRetryTimes(3).setTimeOut(60000);
		site.setCharset("UTF-8");
		return site;
	}

	@Override
	public void process(Page page) {
		System.out.println(page.getHtml().toString());
	}

	public static void main(String[] args){
		new Proxytest().run();
		System.out.println("pass");
	}

}
